import os
from dotenv import load_dotenv

# 加载环境变量
load_dotenv()

class Config:
    """配置类"""
    
    # ZhipuAI配置
    ZHIPU_API_KEY = os.getenv("ZHIPU_API_KEY", "your_api_key_here")
    MODEL_NAME = "glm-4-flash"
    
    # 文件配置
    UPLOAD_DIR = "uploads"
    MAX_FILE_SIZE = 10 * 1024 * 1024  # 10MB
    ALLOWED_EXTENSIONS = ['.pdf']
    
    # Agent配置
    MAX_TOKENS = 128000  # GLM-4-Flash最大上下文
    TEMPERATURE = 0.3
    
    # 应用配置
    PAGE_TITLE = "PaperPal - 论文速读Agent"
    PAGE_ICON = "📚"
    
    @classmethod
    def validate_config(cls):
        """验证配置是否正确"""
        if cls.ZHIPU_API_KEY == "your_api_key_here":
            raise ValueError("请设置正确的ZHIPU_API_KEY")
        
        # 创建上传目录
        os.makedirs(cls.UPLOAD_DIR, exist_ok=True)
        
        return True